package com.dbh.alg.datastructure.stack;

import com.dbh.alg.datastructure.queue.ArrayQueue3;
import com.dbh.alg.datastructure.queue.Queue;

/**
 *
 * 单队列模拟栈
 * @author dongbanghui
 * @date 2025/5/30
 */
public class E05Leetcode225 {

    Queue<Integer> queue = new ArrayQueue3<>(100);

    private int size;
    public void push(int x) {
        queue.offer(x);
        for (int i = 0; i < size; i++) {
            queue.offer(queue.poll());
        }
        size++;
    }

    public int pop() {
        size--;
        return queue.poll();
    }

    public int top() {
        queue.peek();
        return 0;
    }

    public boolean isEmpty() {
        return queue.isEmpty();
    }

}
